package com.geekstudy.week5.config;


import com.geekstudy.week5.entity.DemoEntity;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

@ImportResource(locations = "classpath:bean.xml")
@Configuration
public class Week5BeanConfig {


    @Bean(name = "demoEntity@Bean")
    public DemoEntity demoEntityBean() {
        DemoEntity demoEntity = new DemoEntity();
        demoEntity.setId("20210720203040123456");
        demoEntity.setName("使用注解@Bean");
        demoEntity.setAddress("Week5BeanConfig demoEntityBean()");
        return demoEntity;

    }

    @Bean(name = "demoEntityBeanInit")
    public DemoEntity demoEntityBeanInit() {
        DemoEntity demoEntity = new DemoEntity("demoEntityBeanInit", "使用注解@Bean构造", "Week5BeanConfig demoEntityBeanInit() 使用构造方法 ");
        return demoEntity;
    }
}
